﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;

namespace Client.Common.Converters
{
    [ValueConversion(typeof(int), typeof(Visibility))]
    public class CountToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Visibility res = Visibility.Collapsed;
            bool isShow = true;
            if (value is int count)
            {
                if(count > 0)
                {
                    isShow = false;
                }                
            }
            if (!isShow)
            {
                if (parameter is bool isHidden)
                {
                    if (isHidden)
                    {
                        res = Visibility.Hidden;
                    }
                }
            }
            else
            {
                res = Visibility.Visible;
            }
            return res;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return default(int);
        }
    }
}
